<?php

class Core_Component_System_Controller_Backend_Localize {
    
    public function __construct() {
        $GLOBALS[RC]->getHelper()->setLocation('{system.system}', '{system.localize_index}');
    }
    
    public function mappingAction(){
        return array(
            'create'=>'edit'
        );
    }

    public function indexAction() {
        $list = App::getModel('system/localize')->getQuery()->fetch();
        return $GLOBALS[RC]->getHelper()->templateResult(array('list' => $list));
    }

    public function editAction($id = NULL) {
        $model = App::getModel('system/localize');
        if (!is_null($id)) {
            $model->load($id);
            $GLOBALS[RC]->getHelper()->setLocation($model->getLangName());
        }else{
            $GLOBALS[RC]->getHelper()->setLocation('{system.create_localize}');
        }
        return $GLOBALS[RC]->getHelper()->modelFormResult($model,
                array(),
                '*/*/edit');
    }

    public function saveAction(Core_Component_System_Model_localize $model) {
        $model->merge()->validate()->save();
        return $GLOBALS[RC]->getHelper()->redirectResult('*/*/*/index');
    }

}
